package com.shangxia.common.vo;

import com.shangxia.common.enums.MsgStateENUM;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * @ProjectName: sxcloud
 * @ClassName: ResultVO
 * @Time: 2021/11/14
 * @Author: zhouy
 * @Description:
 * @Experience:
 */

@Slf4j
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResultVO<T> implements Serializable {
    private static final long serialVersionUID = -2705914331599721883L;
    private T data;
    private Integer msgCode;
    private String msg;

    public static ResultVO okResultVO() {
        return new ResultVO(null, MsgStateENUM.OK.getCode(), MsgStateENUM.OK.getReason());
    }

    public static ResultVO okResultVO(Object t) {
        return new ResultVO(t, MsgStateENUM.OK.getCode(), MsgStateENUM.OK.getReason());
    }


    public static ResultVO errorResultVO() {
        return new ResultVO(null, MsgStateENUM.ERROR.getCode(), MsgStateENUM.ERROR.getReason());
    }

    public static ResultVO errorResultVO(MsgStateENUM msgStateENUM) {
        return new ResultVO(null, msgStateENUM.getCode(), msgStateENUM.getReason());
    }

}
